//  this library.
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:hktk_app/model/login/config_model.dart';
import 'package:hktk_app/util/font_util.dart';

// import 'package:hktk_app/util/navigator_util.dart';
import 'package:hktk_app/util/view_util.dart';

/// 提示框内容显示方法
class AskAgreementWidget extends StatefulWidget {
  /// 对应的url
  final AppConfig appConfig;

  const AskAgreementWidget({
    super.key,
    required this.appConfig,
  });

  @override
  State<AskAgreementWidget> createState() => _AskAgreementWidgetState();
}

class _AskAgreementWidgetState extends State<AskAgreementWidget> {
  /// 用户协议 的手势
  late TapGestureRecognizer _yhGestureRecognizer;

  /// 隐私协议 的手势
  late TapGestureRecognizer _ysGestureRecognizer;

  @override
  void initState() {
    super.initState();
    _yhGestureRecognizer = TapGestureRecognizer();
    _ysGestureRecognizer = TapGestureRecognizer();
  }

  @override
  void dispose() {
    super.dispose();
    _yhGestureRecognizer.dispose();
    _ysGestureRecognizer.dispose();
  }

  @override
  Widget build(BuildContext context) {
    double textSize = 16;
    return SingleChildScrollView(child: Text.rich(
      TextSpan(
        children: [
          TextSpan(
              text: "我们非常重视您的个人信息和隐私保护。为了更好地保护您的个人权益，在您使用我们的产品前，请务必审慎阅读",
              style: FontUtil.fontBlack1(textSize)),
          TextSpan(
            text: "“用户协议”",
            style: FontUtil.fontBlue1(textSize),
            recognizer: _yhGestureRecognizer
              ..onTap = () {
                Navigator.pushNamed(context, "/h5", arguments: {
                  "url": widget.appConfig.yhxy!,
                  "title": "用户协议",
                  "showClose": true,
                });
              },
          ),
          TextSpan(text: "和用户", style: FontUtil.fontBlack1(textSize)),
          TextSpan(
            text: "“隐私政策”",
            style: FontUtil.fontBlue1(textSize),
            recognizer: _ysGestureRecognizer
              ..onTap = () {
                Navigator.pushNamed(context, "/h5", arguments: {
                  "url": widget.appConfig.ysxy!,
                  "title": "隐私协议",
                  "showClose": true,
                });
              },
          ),
          TextSpan(
            text:
            "的所有条款。您点击“同意”的行为即表示您已经阅读完毕并同意以上协议及隐私政策的全部内容。如 您同意以上协议及隐私保护政策的内容，请点击”同意“开始我们的产品服务。",
            style: FontUtil.fontBlack1(textSize),
          ),
        ],
      ),
    ),);

  }
}
